<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Prediction Result</title>
    <style>
        body {
            font-family: 'Arial', sans-serif;
            margin: 0;
            padding: 0;
            background-color: #f4f4f9;
            color: #333;
        }

        header {
            background-color: #2e3b4e;
            color: white;
            padding: 20px 0;
            text-align: center;
        }

        h1 {
            font-size: 2.5rem;
            margin: 0;
        }

        .container {
            width: 80%;
            margin: 30px auto;
            padding: 30px;
            background-color: white;
            border-radius: 8px;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
        }

        .result-section {
            text-align: center;
            margin-bottom: 30px;
            padding-bottom: 20px;
            border-bottom: 1px solid #eee;
        }

        .email-content {
            background-color: #f9f9f9;
            padding: 15px;
            border-radius: 5px;
            margin: 20px 0;
            text-align: left;
            border-left: 4px solid #3498db;
        }

        .result {
            font-size: 2rem;
            font-weight: bold;
            margin: 20px 0;
        }

        .result.phishing {
            color: #e74c3c;
        }

        .result.not-phishing {
            color: #2ecc71;
        }

        .probability {
            font-size: 1.2rem;
            color: #555;
            margin-bottom: 20px;
        }

        .back-btn {
            background-color: #3498db;
            color: white;
            font-size: 1.1rem;
            padding: 12px 20px;
            border: none;
            border-radius: 5px;
            text-decoration: none;
            transition: background-color 0.3s;
            display: inline-block;
            margin-top: 20px;
        }

        .back-btn:hover {
            background-color: #2980b9;
        }

        .log-container {
            margin-top: 30px;
        }

        .log-heading {
            font-size: 1.5rem;
            margin-bottom: 15px;
            color: #2e3b4e;
        }

        .log-content {
            height: 300px;
            overflow-y: auto;
            background-color: #f5f5f5;
            padding: 15px;
            border-radius: 5px;
            font-family: monospace;
            font-size: 0.9rem;
            white-space: pre-wrap;
            text-align: left;
            border: 1px solid #ddd;
        }

        .nav-links {
            text-align: center;
            margin: 20px 0;
        }

        .nav-link {
            display: inline-block;
            margin: 0 10px;
            padding: 10px 15px;
            background-color: #3498db;
            color: white;
            text-decoration: none;
            border-radius: 5px;
            transition: background-color 0.3s;
        }

        .nav-link:hover {
            background-color: #2980b9;
        }

        footer {
            text-align: center;
            font-size: 0.9rem;
            padding: 15px;
            background-color: #2e3b4e;
            color: white;
            margin-top: 30px;
        }
    </style>
</head>
<body>

<header>
    <h1>Phishing Email Prediction Result</h1>
</header>

<div class="container">
    <div class="nav-links">
        <a href="/" class="nav-link">首页</a>
        <a href="/visualize" class="nav-link">查看模型性能</a>
    </div>

    <div class="result-section">
        <h2>Your email has been analyzed!</h2>
        <p class="result {{ result|lower }}">{{ result }}</p>
        <p class="probability">Prediction probability: {{ prediction_value|round(4) }}</p>
        
        <h3>Email Content:</h3>
        <div class="email-content">
            {{ email_content|nl2br }}
        </div>
        
        <a href="/" class="back-btn">Analyze Another Email</a>
    </div>
    
    <div class="log-container">
        <h3 class="log-heading">Prediction History Log</h3>
        <div class="log-content">{{ log_content }}</div>
    </div>
</div>

<footer>
    <p>&copy; 2025 Phishing Email Detection. All rights reserved.</p>
</footer>
<script>
    // 弹窗提醒钓鱼邮件
    window.addEventListener('DOMContentLoaded', function () {
        const result = "{{ result|lower }}";
        if (result === "phishing") {
            alert("⚠️ 警告：该邮件被判定为钓鱼邮件，请勿点击其中的链接或下载附件！");
        }
    });
</script>
</body>
</html>
